package com.hqyj.system.service.impl;

import com.github.pagehelper.PageHelper;
import com.hqyj.system.mapper.FinanceMapper;
import com.hqyj.system.model.Finance;
import com.hqyj.system.service.FinanceService;
import frame.pageUtil.PageBeanUtil;
import frame.pageUtil.PagedResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FinanceServiceImpl implements FinanceService {
    @Autowired
    FinanceMapper financeMapper;

    @Override
    public List<Finance> queryAllFinance() {
        return financeMapper.queryAllFinance();
    }

    @Override
    public PagedResult<Finance> getAllFinancePageByPage(Integer pageNumber, Integer pageSize) {
        // 1.调用分页插件
        PageHelper.startPage(pageNumber, pageSize);
        //2.查询数据库获取数据
        List<Finance> financeList = financeMapper.queryAllFinance();
        // 3.通过分页工具类加载分页数据
        return PageBeanUtil.toPagedResult(financeList);
    }
}
